<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!-- 编辑器 -->
<script type="text/javascript">

$(function(){
	//初始化表单验证
	$("#addForm").validate({
		ignore: "",
		 rules:{link:{url:true}}, 
		messages:{
			title: {required: "请输入标题"},
			describe: {required: "请输入概要"},
			categoryid: {required: "请选择分类"},
			thumb: {required: "请添加图片"},
			link: {required: "请输入链接"}
		},
		submitHandler:function(form){
			$(form).ajaxSubmit({
				success:function(data){
					switch(data.flag){
					case 6:
						Kit.alert("图片上传失败，请重新上传");return;
					case -1:
						Kit.alert("网络繁忙...，请重试");return;
					case 0:
						dataPaginator.loadPage(1);
						addDialog.close();
					}
				}
			});
		}
	});
});

</script>
<form id="addForm" action="${BASE_PATH}/wx/article/doAdd" method="post" class="form-horizontal" enctype="multipart/form-data">
	<div class="form-group">
	    <label class="col-lg-2 control-label">名称</label>
	    <div class="col-lg-9">
        	<input type="text" name="title" value="" class="form-control" placeholder="请输入标题" required maxlength="100">
	    </div>
	</div>
	<div class="form-group">
	    <label class="col-lg-2 control-label">描述</label>
	    <div class="col-lg-9">
        	<input type="text" name="describe" value="" class="form-control" placeholder="请输入概要" required maxlength="100">
	    </div>
	</div>
	<div class="form-group">
	    <label class="col-lg-2 control-label">分类</label>
	    <div class="col-lg-9">
	        <select name="categoryid" class="selectpicker form-control" data-url="${BASE_PATH}/wx/article/category/all?mp=${mp}" data-issingle="true" data-key="id:name" required></select>
	    </div>
	</div>
	<div class="form-group">
	    <label class="col-lg-2 control-label">显示</label>
	    <div class="col-lg-9">
        	<ul class="iCheckList">
	    		<li><input type="radio" class="iCheck" name="isTop" value="1"> 是</li>
	    		<li><input type="radio" class="iCheck" name="isTop" value="0" checked> 否</li>
	    	</ul>
	    </div>
	</div>
	<div class="form-group">
		<label class="col-lg-2 control-label">缩略图</label>
		<div class="col-lg-9">
			<input type="file" id="thumb" name="thumb" accept="image/jpg,image/png" title="选择文件" required>
		</div>
		<div class="col-lg-offset-2 p-t-5 col-lg-9"><span class="text-success">*建议640px*360px，大小30K以内，建议PNG格式，支持JPEG、PNG</span></div>
	</div>
	<div class="form-group">
	    <label class="col-lg-2 control-label">连接</label>
	    <div class="col-lg-9">
        	<!-- <textarea id="link" name="link" placeholder="请输入内容" required></textarea> -->
        	<input type="text" name="link" value="" class="form-control" placeholder="请输入链接地址" maxlength="200" required>
	    </div>
	</div>
	
	<div class="row">
		<div class="col-lg-6"><button class="btn btn-primary col-sm-3 pull-right" type="submit" autocomplete="off">提交</button></div>
		<div class="col-lg-6"><button class="btn btn-default col-sm-3 pull-left" type="button" onclick="javascript:addDialog.close();" autocomplete="off">取消</button></div>
	</div>
</form>